import { PlayerDialog } from "./PlayerDialog";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { Language } from "../../../../../extend/language/Language";
import { SystemSetter } from "../../system/SystemSetter";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
//class GuildFlameAdd
    
    export  class GuildFlameAdd extends PlayerDialog
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._autoAddFire = new GCheckBox();
            this._autoAddFire.styleName = "GCheckBox";
            this._autoAddFire.label = Language.getString(20516);
            this._autoAddFire.width = 100;
            this._autoAddFire.selected = SystemSetter.currentSetter.autoAddFire;
            this._autoAddFire.addEventListener(flash.events.Event.CHANGE, this.onAutoAddFireSelectedChange);
            this.addChild(this._autoAddFire);
            this._refreshTime = new Object /* flash.text.TextField */();
            this._refreshTime.textColor = GlobalStyle.color1Uint;
            this._refreshTime.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._refreshTime.width = 100;
            this._refreshTime.mouseEnabled = false;
            this._refreshTime.text = "00: 00: 00";
            this._refreshTime.x = this._autoAddFire.x + this._autoAddFire.textField.textWidth + 30;
            this._refreshTime.y = 2;
            addChild(this._refreshTime);
            return;
        }

        /* internal  */onAutoAddFireSelectedChange(arg1: Object /* flash.events.Event */): void
        {
            SystemSetter.localSetter.setSystemInfo("autoAddFire", this._autoAddFire.selected);
            Dispatcher.dispatchEvent(new DataEvent(EventName.Sys_SaveInfoNotShowInWindow));
            return;
        }

        public initData(): void
        {
            this._refreshTime.text = "00: 00: 00";
            Dispatcher.addEventListener(EventName.GuildFlameWoodCoolTimeUpdate, this.onWoodCoolTimeUpdate);
            return;
        }

        /* internal  */onWoodCoolTimeUpdate(arg1: DataEvent): void
        {
            var loc1=int(arg1.data);
            this._refreshTime.text = RemainTimeTool.getRemainTimeBySeconds(loc1);
            return;
        }

        public /* override */ dispose(): void
        {
            super.dispose();
            this._refreshTime.text = "00: 00: 00";
            Dispatcher.removeEventListener(EventName.GuildFlameWoodCoolTimeUpdate, this.onWoodCoolTimeUpdate);
            return;
        }

        public /* override */ get height(): number
        {
            return 22;
        }

        /* internal */ /* var */_autoAddFire: GCheckBox;

        /* internal */ /* var */_refreshTime: Object /* flash.text.TextField */;

        /* internal */ /* var */_timer: SecTimer;
    }
